package com.cmcc.passenger.ui.profile

import android.os.Bundle
import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.databinding.DataBindingUtil
import com.alibaba.android.arouter.facade.annotation.Route
import com.cmcc.passenger.R
import com.cmcc.passenger.config.AppConfig

import com.cmcc.passenger.config.PassPath
import com.cmcc.passenger.databinding.ActivityRegistAgreeBinding
import com.cmcc.passenger.ui.base.BasicActivity
import com.cmcc.shared.SdkManager
import com.cmcc.shared.utils.L

/**
 * Author: weishixiong
 * Date: 2020/03/23
 * Description:
 */
@Route(path = PassPath.AGREE)
class AgreeActivity : BasicActivity() {

    override fun initialize(savedInstanceState: Bundle?) {
        val binding = DataBindingUtil.setContentView<ActivityRegistAgreeBinding>(
            this,
            R.layout.activity_regist_agree
        )

        binding.appbar.title.text = getString(R.string.str_agree)

        binding.appbar.toolbar.setNavigationOnClickListener { finish() }

        val webSettings = binding.webview.settings
        webSettings.javaScriptEnabled = true
        webSettings.javaScriptCanOpenWindowsAutomatically = true
        webSettings.allowFileAccess = true// 设置允许访问文件数据
        webSettings.setSupportZoom(true)//支持缩放
        webSettings.javaScriptCanOpenWindowsAutomatically = true
        webSettings.cacheMode = WebSettings.LOAD_NO_CACHE
        webSettings.domStorageEnabled = true
        webSettings.databaseEnabled = true

        binding.webview.webViewClient = webClient
        binding.webview.loadUrl(
            when (SdkManager.getLanguage()) {
                0 -> AppConfig.REGISTRATION_AGREEMENT_EN
                else -> AppConfig.REGISTRATION_AGREEMENT
            }
        )
    }

    private val webClient = object : WebViewClient() {
        override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
            L.d("loading------articlesOfLaw", url!!)
            return false
        }
    }


}